function my_legend(varargin)
%LEGEND Graph legend.
% simple version that doesn't overwritie the axes user data..... ha ha.
%
%
% p. manis 7/10/01.

axh = varargin(1);
if(~ishandle(axh))
   return;
end;
j = 0;
for i = 2:2:length(varargin)
   j = j + 1;
   leg(j).title = varargin(i);
   leg(j).mark = varargin(i+1);
end;
nleg = j;
p = get(axh, 'Position'); % get position of the figure
hfig = get(axh, 'Parent'); % get the parent figure. The legend belongs t the parent.
p2 = [p(1) p(2)+p(4) p(2)/4 p(4)];
hleg = uicontrol( ...
   'Parent', hfig, ...
   'Type', 'text', ...
   'String', '', ...
   'Units', 'normalized', ...
   'background', [1 1 1], ...
   'Position', p2 ...
);
s = []
for i = 1:nleg
   s = [s sprintf('%s %s\r\n', leg(i).title, leg(i).mark)];
end;
set(hleg, 'String', s);
return;

